#include "filesystemdevice.h"
#include "filesystem.h"
#include <sys/stat.h>

FilesystemDevice::FilesystemDevice()
{
    executionPath = "";
}

std::string FilesystemDevice::getPath()
{
    return fixSlashes(getAppPath(), SLASHES_TO_STANDARD).c_str();
}

std::string FilesystemDevice::getExecutionPath()
{
    return fixSlashes(executionPath, SLASHES_TO_STANDARD).c_str();
}

void FilesystemDevice::setExecutionPath(std::string np)
{
    executionPath = np;
}

std::string FilesystemDevice::getFileName(std::string fullpath)
{
    return ::getFileName(fullpath);
}

std::string FilesystemDevice::getFilePath(std::string fullpath)
{
    return ::getFilePath(fullpath);
}

void FilesystemDevice::getDirectory(std::string path,
    std::vector<std::string> &files, std::string ext)
{
    ::getDirectory(path, files, ext);
}

int FilesystemDevice::isDirectory(std::string path)
{
	struct stat dstat;
	/*
	char pEnd = path.at(path.size() - 1);
	if( pEnd != '\\' && pEnd != '/' )
		path.push_back('\\');
	*/

	/*int success = */stat(path.c_str(), &dstat);

	if( S_ISDIR(dstat.st_mode) )
		return true;
	else
		return false;
}
